package com.mygame.common.protobuf;

import com.mygame.common.codec.DataCodecKit;
import com.mygame.common.msg.CommandEnum;

public class ExternalMessageUtil {

    public static ExternalMessage build(CommandEnum commandEnum, Object obj){
        ExternalMessage message = new ExternalMessage();
        message.setMessageId(commandEnum.id);
        message.setServiceId(commandEnum.service.id);
        message.setData(DataCodecKit.encode(obj));
        return message;
    }

    public static ExternalMessage build(CommandEnum commandEnum, int errorCode){
        ExternalMessage message = new ExternalMessage();
        message.setMessageId(commandEnum.id);
        message.setServiceId(commandEnum.service.id);
        message.setErrorCode(errorCode);
        return message;
    }

}
